//
//  SeekToProgress.m
//  SeekToProgress
//
//  Created by Burn on 2019/7/11.
//  Copyright © 2019 menksoft. All rights reserved.
//

#import "SeekToProgress.h"

@interface SeekToProgress ()

@property(strong,nonatomic) UIProgressView *pro;
@property(strong,nonatomic) UILabel *proL;
@property(copy,nonatomic)NSString *total;


@end

@implementation SeekToProgress

- (instancetype)initWithFrame:(CGRect)frame pro:(CGFloat)progress total:(NSString *)total{
    if (self = [super initWithFrame:frame]) {
        self.progress = progress;
        self.total = total;
        [self ui];
    }
    return self;
}

- (void)ui{
    self.pro = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleDefault];
    self.pro.tintColor = [[UIColor cyanColor] colorWithAlphaComponent:.5];
    [self addSubview:self.pro];
    
    self.proL = [[UILabel alloc]init];
    self.proL.textColor = [UIColor whiteColor];
    self.proL.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.proL];
    
    self.layer.cornerRadius = 3;
    self.layer.masksToBounds = YES;
    self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:.4];

}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.pro.frame = CGRectMake(4, self.frame.size.height - 15, self.bounds.size.width - 8, 5);
   
    self.proL.frame = CGRectMake(0, 5, self.frame.size.width, 30);
}

- (void)setProgress:(CGFloat)progress{
    _progress = progress;
    self.pro.progress = progress;
}

- (void)setTimes:(NSString *)times{
    _times = times;
    self.proL.text = [NSString stringWithFormat:@"%@/%@",times,self.total];
}
@end
